Load the necessary libraries
library(tidyverse) # for data wrangling etc
library(vegan)
library(ggvegan)
library(ggrepel)
library(GGally)
library(corrplot)
library(mvabund)
library(gllvm)
library(EcolUtils)
library(car)
library(glmmTMB)
library(scales)
macnally <- read.csv("../public/data/macnally_full.csv", strip.white = TRUE)
head(macnally)
macnally[1:5, 1:5]
macnally.std <-
macnally %>%
dplyr::select(-HABITAT) %>%
decostand(method = "total", MARGIN = 2)
macnally.std
macnally.dist <- vegdist(macnally.std, method = "bray")
macnally.capscale <- capscale(macnally.dist ~ 1, data = macnally$HABITAT)
macnally.capscale <- capscale(macnally[, -1] ~ 1, data = macnally$HABITAT)
summary(macnally.capscale, display = NULL)
##
## Call:
## capscale(formula = macnally[, -1] ~ 1, data = macnally$HABITAT)
##
## Partitioning of mean squared Euclidean distance:
## Inertia Proportion
## Total 1394 1
## Unconstrained 1394 1
##
## Eigenvalues, and their contribution to the mean squared Euclidean distance
##
## Importance of components:
## MDS1 MDS2 MDS3 MDS4 MDS5 MDS6
## Eigenvalue 354.8090 293.9379 149.8328 107.27295 82.73498 60.39848
## Proportion Explained 0.2544 0.2108 0.1074 0.07693 0.05933 0.04331
## Cumulative Proportion 0.2544 0.4652 0.5727 0.64959 0.70892 0.75223
## MDS7 MDS8 MDS9 MDS10 MDS11 MDS12
## Eigenvalue 51.05865 42.03806 34.77007 27.16247 25.31312 22.22248
## Proportion Explained 0.03661 0.03015 0.02493 0.01948 0.01815 0.01594
## Cumulative Proportion 0.78885 0.81899 0.84393 0.86341 0.88156 0.89750
## MDS13 MDS14 MDS15 MDS16 MDS17 MDS18
## Eigenvalue 18.65504 16.33075 15.3458 12.290986 10.799840 9.079121
## Proportion Explained 0.01338 0.01171 0.0110 0.008814 0.007745 0.006511
## Cumulative Proportion 0.91087 0.92258 0.9336 0.942402 0.950147 0.956657
## MDS19 MDS20 MDS21 MDS22 MDS23 MDS24
## Eigenvalue 8.496259 7.459807 6.025664 5.931750 5.128363 4.416591
## Proportion Explained 0.006093 0.005349 0.004321 0.004254 0.003678 0.003167
## Cumulative Proportion 0.962750 0.968100 0.972421 0.976674 0.980352 0.983519
## MDS25 MDS26 MDS27 MDS28 MDS29 MDS30
## Eigenvalue 4.00184 3.666642 2.959379 2.564667 2.260893 1.984460
## Proportion Explained 0.00287 0.002629 0.002122 0.001839 0.001621 0.001423
## Cumulative Proportion 0.98639 0.989018 0.991140 0.992980 0.994601 0.996024
## MDS31 MDS32 MDS33 MDS34 MDS35 MDS36
## Eigenvalue 1.738514 1.505069 0.8378910 0.7337122 0.453209 0.2762420
## Proportion Explained 0.001247 0.001079 0.0006009 0.0005261 0.000325 0.0001981
## Cumulative Proportion 0.997271 0.998350 0.9989508 0.9994769 0.999802 1.0000000
##
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:
plot(macnally.capscale)
autoplot(macnally.capscale, geom = "text") + theme_bw()
macnally.mds <- metaMDS(macnally[, -1], k = 2, plot = TRUE)
## Square root transformation
## Wisconsin double standardization
## Run 0 stress 0.1175806
## Run 1 stress 0.1175806
## ... New best solution
## ... Procrustes: rmse 1.8304e-05 max resid 9.379846e-05
## ... Similar to previous best
## Run 2 stress 0.1331716
## Run 3 stress 0.1331716
## Run 4 stress 0.1501146
## Run 5 stress 0.1175806
## ... Procrustes: rmse 3.808574e-05 max resid 0.0001945461
## ... Similar to previous best
## Run 6 stress 0.1175806
## ... Procrustes: rmse 2.949312e-05 max resid 0.0001508359
## ... Similar to previous best
## Run 7 stress 0.1175806
## ... Procrustes: rmse 1.968237e-05 max resid 0.0001012392
## ... Similar to previous best
## Run 8 stress 0.1175806
## ... New best solution
## ... Procrustes: rmse 1.162033e-05 max resid 5.936577e-05
## ... Similar to previous best
## Run 9 stress 0.1175806
## ... Procrustes: rmse 1.928266e-05 max resid 9.862421e-05
## ... Similar to previous best
## Run 10 stress 0.1175806
## ... Procrustes: rmse 1.832597e-05 max resid 9.403822e-05
## ... Similar to previous best
## Run 11 stress 0.1331716
## Run 12 stress 0.1331716
## Run 13 stress 0.1175806
## ... Procrustes: rmse 7.432278e-05 max resid 0.0003812502
## ... Similar to previous best
## Run 14 stress 0.1175806
## ... Procrustes: rmse 3.632866e-05 max resid 0.0001833924
## ... Similar to previous best
## Run 15 stress 0.1175806
## ... Procrustes: rmse 3.101418e-06 max resid 1.115413e-05
## ... Similar to previous best
## Run 16 stress 0.1331717
## Run 17 stress 0.1175846
## ... Procrustes: rmse 0.0007446531 max resid 0.003854777
## ... Similar to previous best
## Run 18 stress 0.1331716
## Run 19 stress 0.1175807
## ... Procrustes: rmse 0.000106216 max resid 0.0005445694
## ... Similar to previous best
## Run 20 stress 0.1175807
## ... Procrustes: rmse 6.86865e-05 max resid 0.000331418
## ... Similar to previous best
## *** Solution reached
macnally.mds
##
## Call:
## metaMDS(comm = macnally[, -1], k = 2, plot = TRUE)
##
## global Multidimensional Scaling using monoMDS
##
## Data: wisconsin(sqrt(macnally[, -1]))
## Distance: bray
##
## Dimensions: 2
## Stress: 0.1175806
## Stress type 1, weak ties
## Two convergent solutions found after 20 tries
## Scaling: centring, PC rotation, halfchange scaling
## Species: expanded scores based on 'wisconsin(sqrt(macnally[, -1]))'
# OR
macnally.std <- wisconsin(macnally[, c(-1)]^0.25)
macnally.dist <- vegdist(macnally.std, "bray")
macnally.mds1 <- metaMDS(macnally.std, k = 2, plot = TRUE)
## Run 0 stress 0.1207534
## Run 1 stress 0.1207536
## ... Procrustes: rmse 0.0003550837 max resid 0.001854227
## ... Similar to previous best
## Run 2 stress 0.1207532
## ... New best solution
## ... Procrustes: rmse 0.0002307792 max resid 0.001212106
## ... Similar to previous best
## Run 3 stress 0.1638184
## Run 4 stress 0.1207535
## ... Procrustes: rmse 0.0002123196 max resid 0.001116477
## ... Similar to previous best
## Run 5 stress 0.1886273
## Run 6 stress 0.1207533
## ... Procrustes: rmse 8.948537e-05 max resid 0.0004681574
## ... Similar to previous best
## Run 7 stress 0.1207535
## ... Procrustes: rmse 0.0001824052 max resid 0.0009578003
## ... Similar to previous best
## Run 8 stress 0.1207532
## ... New best solution
## ... Procrustes: rmse 7.881991e-05 max resid 0.0004145384
## ... Similar to previous best
## Run 9 stress 0.1207532
## ... Procrustes: rmse 7.005219e-05 max resid 0.0003673925
## ... Similar to previous best
## Run 10 stress 0.1656716
## Run 11 stress 0.1207532
## ... New best solution
## ... Procrustes: rmse 2.952071e-06 max resid 1.117432e-05
## ... Similar to previous best
## Run 12 stress 0.1554159
## Run 13 stress 0.1293609
## Run 14 stress 0.1293609
## Run 15 stress 0.1207534
## ... Procrustes: rmse 0.0001498846 max resid 0.0007784816
## ... Similar to previous best
## Run 16 stress 0.1207535
## ... Procrustes: rmse 0.0002378045 max resid 0.001245832
## ... Similar to previous best
## Run 17 stress 0.1207534
## ... Procrustes: rmse 0.0001534994 max resid 0.0008045469
## ... Similar to previous best
## Run 18 stress 0.1752348
## Run 19 stress 0.1293609
## Run 20 stress 0.1207533
## ... Procrustes: rmse 4.634361e-05 max resid 0.0002409522
## ... Similar to previous best
## *** Solution reached
macnally.mds2 <- metaMDS(macnally.dist, k = 2, plot = TRUE)
## Run 0 stress 0.1207534
## Run 1 stress 0.182643
## Run 2 stress 0.1207532
## ... New best solution
## ... Procrustes: rmse 0.0001566514 max resid 0.0008220715
## ... Similar to previous best
## Run 3 stress 0.1207534
## ... Procrustes: rmse 0.0002195054 max resid 0.001150074
## ... Similar to previous best
## Run 4 stress 0.1207534
## ... Procrustes: rmse 0.0001968091 max resid 0.001034387
## ... Similar to previous best
## Run 5 stress 0.1207534
## ... Procrustes: rmse 0.0001566531 max resid 0.0008218563
## ... Similar to previous best
## Run 6 stress 0.1554159
## Run 7 stress 0.1791744
## Run 8 stress 0.1207534
## ... Procrustes: rmse 0.0002193236 max resid 0.001153297
## ... Similar to previous best
## Run 9 stress 0.1905963
## Run 10 stress 0.1207535
## ... Procrustes: rmse 0.0002672699 max resid 0.001406322
## ... Similar to previous best
## Run 11 stress 0.1207533
## ... Procrustes: rmse 0.0001554751 max resid 0.0008177128
## ... Similar to previous best
## Run 12 stress 0.1835332
## Run 13 stress 0.1293609
## Run 14 stress 0.1207534
## ... Procrustes: rmse 0.0002375332 max resid 0.001249172
## ... Similar to previous best
## Run 15 stress 0.1726584
## Run 16 stress 0.1293609
## Run 17 stress 0.1207535
## ... Procrustes: rmse 0.0002644241 max resid 0.001391102
## ... Similar to previous best
## Run 18 stress 0.1207533
## ... Procrustes: rmse 5.476658e-05 max resid 0.0002841039
## ... Similar to previous best
## Run 19 stress 0.1207534
## ... Procrustes: rmse 0.0001739484 max resid 0.0009130141
## ... Similar to previous best
## Run 20 stress 0.1207534
## ... Procrustes: rmse 0.0002478414 max resid 0.001303661
## ... Similar to previous best
## *** Solution reached
stressplot(macnally.mds)
autoplot(macnally.mds) + theme_bw()
macnally.mds.scores <- macnally.mds %>%
fortify() %>%
full_join(macnally %>%
rownames_to_column(var = "Label"))
g <-
ggplot(data = NULL, aes(y = NMDS2, x = NMDS1)) +
geom_hline(yintercept = 0, linetype = "dotted") +
geom_vline(xintercept = 0, linetype = "dotted") +
geom_point(
data = macnally.mds.scores %>% filter(Score == "sites"),
aes(color = HABITAT)
) +
geom_text(
data = macnally.mds.scores %>% filter(Score == "sites"),
aes(label = Label, color = HABITAT), hjust = -0.2
)
g
g + ggforce::geom_mark_ellipse(
data = macnally.mds.scores %>% filter(Score == "sites"),
aes(y = NMDS2, x = NMDS1, fill = HABITAT), expand = 0
)
g <- g + ggforce::geom_mark_hull(
data = macnally.mds.scores %>% filter(Score == "sites"),
aes(y = NMDS2, x = NMDS1, fill = HABITAT), concavity = 10
)
g + theme_bw()
Xmat <- model.matrix(~ -1 + HABITAT, data = macnally)
colnames(Xmat) <- gsub("HABITAT", "", colnames(Xmat))
envfit <- envfit(macnally.mds, env = Xmat)
envfit
##
## ***VECTORS
##
## NMDS1 NMDS2 r2 Pr(>r)
## Box-Ironbark -0.02786 0.99961 0.2940 0.004 **
## Foothills Woodland 0.31838 0.94796 0.0325 0.592
## Gipps.Manna -0.10673 -0.99429 0.4032 0.001 ***
## Mixed 0.50280 -0.86440 0.1574 0.056 .
## Montane Forest 0.78938 0.61390 0.1145 0.117
## River Red Gum -0.86474 0.50223 0.5618 0.001 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 999
data.env.scores <- envfit %>% fortify()
g <- g +
geom_segment(
data = data.env.scores,
aes(y = 0, x = 0, yend = NMDS2, xend = NMDS1),
arrow = arrow(length = unit(0.3, "lines")), color = "blue"
) +
geom_text(
data = data.env.scores,
aes(y = NMDS2 * 1.1, x = NMDS1 * 1.1, label = Label), color = "blue"
)
g + theme_bw()
Similarity percentage: decomposition of Bray-Curtis index into contributions of each species to average between-group dissim.
Pairwise displays most important species for each pair. Caused by variation in species abundances and only partly by differences among groups. So driven by most abundant species.
simper(macnally.std, macnally$HABITAT)
## cumulative contributions of most influential species:
##
## $Mixed_Gipps.Manna
## WPHE WAG WSW WTTR CR NHHE RWB
## 0.03829487 0.07619258 0.11222544 0.13814230 0.16365411 0.18731342 0.21077957
## CST FTC GF LR ER STTH DWS
## 0.23318133 0.25493169 0.27604853 0.29702785 0.31786072 0.33867098 0.35888118
## RWH NMIN GWH STP YFHE EYR WEHE
## 0.37894072 0.39877878 0.41806667 0.43618448 0.45400605 0.47173441 0.48942422
## SIL WBSW SHBC ESP BFCS SFW AUR
## 0.50705736 0.52441277 0.54153413 0.55822987 0.57474126 0.59118666 0.60734222
## LWB BTH RF SPP WNHE VS LK
## 0.62270008 0.63727478 0.65174682 0.66557291 0.67862146 0.69156744 0.70360945
##
## $`Mixed_Montane Forest`
## PCU STHR GCU RWH WHIP GGC SFC
## 0.02764874 0.05242458 0.07675145 0.10011482 0.12342676 0.14649711 0.16902947
## LYRE ER YTBC PIL RF VS STP
## 0.19132679 0.21244249 0.23349089 0.25416445 0.27482588 0.29484403 0.31414144
## RWB LR CST SHBC BFCS LHE AUR
## 0.33247790 0.35074746 0.36892776 0.38707082 0.40464607 0.42145878 0.43788243
## BHHE BCOO CHE RBTR YFHE WWCH SIL
## 0.45419504 0.47028794 0.48633339 0.50195144 0.51713704 0.53215029 0.54695995
## NHHE GBB SPP ROSE SCR RBFT WEHE
## 0.56165026 0.57573370 0.58944564 0.60292020 0.61612257 0.62926269 0.64212394
## STTH WBSW FTC CR GWH
## 0.65476550 0.66711080 0.67914517 0.69115364 0.70286598
##
## $`Mixed_Foothills Woodland`
## SCR WWCH SKF BRTH MB WBSW YTH
## 0.03335799 0.06032622 0.08684197 0.11266809 0.13802927 0.16227496 0.18579408
## VS PCU CST ER RF STP SHBC
## 0.20912850 0.23078715 0.25172635 0.27237490 0.29190863 0.31117749 0.33036599
## LR GCU BHHE CHE AUR SIL SFW
## 0.34895615 0.36710866 0.38505067 0.40245713 0.41968612 0.43560623 0.45128706
## RBFT BFCS NHHE SPP YTBC SFC WHIP
## 0.46677247 0.48223986 0.49729009 0.51217079 0.52631521 0.54030385 0.55397270
## WEHE YFHE RWB STTH GWH EYR RBTR
## 0.56713251 0.57971261 0.59209274 0.60428204 0.61636000 0.62842520 0.64028015
## DWS DF BELL OBO FTC CR
## 0.65210758 0.66392057 0.67564935 0.68727862 0.69888237 0.71027370
##
## $`Mixed_Box-Ironbark`
## YTH WWCH WBSW RCR SCR BHHE OBO
## 0.03129318 0.06179241 0.09106440 0.11940883 0.14718850 0.17312612 0.19887926
## FHE ESP CBW FTC BRTH MUSK VS
## 0.22152324 0.24270224 0.26363300 0.28381463 0.30368648 0.32256172 0.34038864
## WTG GCU SHBC ER EYR LR RF
## 0.35702187 0.37322029 0.38937768 0.40488357 0.42024078 0.43546725 0.45009397
## CR STP CST SPW RWB AUR RBFT
## 0.46470129 0.47921729 0.49349084 0.50766572 0.52150463 0.53419336 0.54668340
## YFHE RSL GWH GBB NHHE SIL SPP
## 0.55912326 0.57145844 0.58349723 0.59535172 0.60714373 0.61890354 0.63057695
## YTBC BFCS BTH CHE WEHE WHIP GF
## 0.64210964 0.65357506 0.66494984 0.67622838 0.68746057 0.69860551 0.70951879
##
## $`Mixed_River Red Gum`
## BTH WBSW EYR GAL WEHE LFB CR
## 0.02263347 0.04449196 0.06522358 0.08578260 0.10558139 0.12487100 0.14412524
## MGLK WWCH BTR RFC WAG DB SKF
## 0.16326320 0.18208804 0.20038221 0.21856435 0.23671000 0.25399762 0.27125455
## SPP WPHE AMAG WNHE JW RBEE ESP
## 0.28807298 0.30485004 0.32144276 0.33781905 0.35401716 0.36999968 0.38581483
## SCC FTC RWH RSL FLAME GWH RWB
## 0.40153685 0.41706226 0.43253219 0.44671301 0.46056281 0.47424816 0.48792623
## STP STTH YFHE WTTR SHBC NMIN YR
## 0.50132483 0.51469583 0.52783199 0.54081433 0.55366277 0.56613483 0.57829889
## VS WWT SIL CST WG WTG GF
## 0.59025578 0.60209852 0.61391524 0.62570191 0.63724531 0.64878871 0.66021929
## ER OBO PCU CRP
## 0.67140439 0.68251374 0.69360888 0.70456623
##
## $`Gipps.Manna_Montane Forest`
## WPHE WAG WSW NHHE RWB PCU ER
## 0.04187735 0.07890614 0.11395553 0.14299820 0.17150727 0.19883824 0.22613673
## CST WTTR CR GCU SFC BFCS WHIP
## 0.25124798 0.27594232 0.30023898 0.32404547 0.34573831 0.36624805 0.38644715
## SHBC STTH FTC YTBC LR SIL STHR
## 0.40661513 0.42623453 0.44543782 0.46454515 0.48291025 0.50095222 0.51879667
## DWS NMIN GF RF GGC LYRE RWH
## 0.53664016 0.55415509 0.57159781 0.58895232 0.60615683 0.62287364 0.63925513
## WEHE YFHE PIL GWH
## 0.65537387 0.67123709 0.68627350 0.70129841
##
## $`Gipps.Manna_Foothills Woodland`
## WPHE WAG WSW SCR WTTR WBSW NHHE
## 0.04675699 0.08810045 0.12723386 0.15816680 0.18815895 0.21782832 0.24612577
## CR SKF WWCH STTH VS ER RWB
## 0.27161076 0.29688477 0.31975029 0.34248698 0.36463396 0.38674729 0.40844839
## FTC BRTH SFW DWS RWH YTH NMIN
## 0.42988928 0.45104625 0.47098749 0.49091014 0.51072999 0.53049720 0.55005301
## GF SHBC CST MB PCU EYR GWH
## 0.56936325 0.58831183 0.60696810 0.62480986 0.64175323 0.65843959 0.67510298
## WEHE BHHE
## 0.69170952 0.70772420
##
## $`Gipps.Manna_Box-Ironbark`
## WPHE WBSW WAG WSW WWCH YTH NHHE
## 0.04139579 0.08099168 0.11759466 0.15224100 0.18128165 0.21026523 0.23897393
## SCR WTTR CST OBO RCR BHHE EYR
## 0.26667314 0.29269643 0.31845815 0.34408843 0.36856422 0.39249786 0.41545224
## FHE LR FTC STTH CBW SIL BRTH
## 0.43658595 0.45711260 0.47609506 0.49481416 0.51288814 0.53069749 0.54844201
## DWS NMIN RWH VS MUSK ER STP
## 0.56608031 0.58339383 0.60052715 0.61758205 0.63455972 0.65140376 0.66802272
## GCU GWH GF
## 0.68412853 0.69955499 0.71480216
##
## $`Gipps.Manna_River Red Gum`
## WBSW EYR RWB SPP NHHE WNHE SKF
## 0.03594753 0.07097913 0.10334400 0.13006862 0.15613211 0.18166795 0.20580620
## WEHE RFC WWCH LFB AMAG BTR YFHE
## 0.22908782 0.25136720 0.27331285 0.29451599 0.31550750 0.33633062 0.35713098
## WSW SCC DB GAL MGLK RBEE FTC
## 0.37737562 0.39651883 0.41529923 0.43394264 0.45174509 0.46902999 0.48626341
## JW SFW BTH DWS FLAME NMIN WPHE
## 0.50326871 0.52016906 0.53685531 0.55286841 0.56859561 0.58431386 0.59911553
## LR CST RWH GWH RSL YR WWT
## 0.61373460 0.62776853 0.64133550 0.65464035 0.66789875 0.68066897 0.69310186
## WG
## 0.70522050
##
## $`Montane Forest_Foothills Woodland`
## SKF SCR WHIP WWCH YTBC BRTH MB
## 0.03522743 0.06839753 0.09983201 0.12985558 0.15959100 0.18908002 0.21802813
## STHR YTH GGC SFC LYRE PCU RF
## 0.24579822 0.27335016 0.30012436 0.32643290 0.35244813 0.37739626 0.40212713
## WBSW RWH PIL VS CST GCU ER
## 0.42677151 0.45110510 0.47450522 0.49669301 0.51861897 0.54011825 0.55955265
## STP BHHE RBTR BFCS CHE AUR LR
## 0.57892315 0.59799926 0.61657936 0.63466529 0.65218552 0.66959065 0.68649361
## LHE
## 0.70328688
##
## $`Montane Forest_Box-Ironbark`
## YTH PCU OBO WBSW RCR WWCH SCR
## 0.03470014 0.06704544 0.09773090 0.12825716 0.15756041 0.18575799 0.21232490
## SFC FHE WHIP SHBC BHHE ESP FTC
## 0.23799766 0.26329966 0.28720463 0.31100313 0.33378986 0.35650259 0.37918577
## YTBC CBW RWB BRTH STHR RF GGC
## 0.40179866 0.42343745 0.44483266 0.46607701 0.48719533 0.50773382 0.52809478
## MUSK LYRE RWH PIL WTG ER STP
## 0.54842102 0.56820481 0.58705382 0.60484891 0.62204479 0.63756195 0.65297668
## VS SPW BFCS LR
## 0.66797608 0.68263047 0.69672753 0.70989150
##
## $`Montane Forest_River Red Gum`
## BTH SKF GAL WBSW WPHE SHBC MGLK
## 0.02185502 0.04307104 0.06409547 0.08444112 0.10446325 0.12445679 0.14423333
## RFC WAG CR EYR GCU SPP LFB
## 0.16381552 0.18328354 0.20244818 0.22144632 0.24022432 0.25891727 0.27755351
## AMAG BTR SFC SCC WWCH DB WHIP
## 0.29600375 0.31430597 0.33141678 0.34824247 0.36502760 0.38153440 0.39746699
## FTC WEHE RBEE ESP YTBC JW ER
## 0.41337835 0.42887636 0.44406872 0.45920668 0.47427809 0.48922470 0.50367686
## STHR FLAME RF GGC WNHE RSL LYRE
## 0.51775215 0.53157538 0.54526421 0.55883473 0.57231844 0.58555328 0.59873911
## PCU SIL STTH PIL BFCS YFHE NMIN
## 0.61154135 0.62379234 0.63593927 0.64779963 0.65963801 0.67117739 0.68268583
## WTTR YR
## 0.69401372 0.70523795
##
## $`Foothills Woodland_Box-Ironbark`
## RCR SKF FTC FHE OBO ESP MB
## 0.03978989 0.07616631 0.11062393 0.14498066 0.17841323 0.20906943 0.23896171
## CBW MUSK SHBC PCU BHHE LR WTG
## 0.26834429 0.29594460 0.32240419 0.34679047 0.37091046 0.39496508 0.41831478
## CST SPW WBSW STP ER GCU YTH
## 0.44095588 0.46309711 0.48505901 0.50662758 0.52705080 0.54737402 0.56662894
## VS BRTH WWCH EYR DF RSL AUR
## 0.58526920 0.60383041 0.62196003 0.63845143 0.65485075 0.67122611 0.68698785
## RWB
## 0.70142114
##
## $`Foothills Woodland_River Red Gum`
## SPP SCR GAL BTH WPHE MGLK RFC
## 0.02552963 0.05002193 0.07358575 0.09652353 0.11896399 0.14112921 0.16307660
## WAG EYR LFB AMAG BTR WEHE CR
## 0.18489602 0.20619458 0.22708177 0.24776048 0.26827330 0.28873756 0.30891624
## FTC SCC DB RWH RBEE ESP SHBC
## 0.32876119 0.34761914 0.36611969 0.38343461 0.40046194 0.41732673 0.43408273
## JW BRTH YFHE FLAME WNHE RSL RWB
## 0.45083463 0.46758644 0.48397939 0.49947222 0.51473507 0.52956845 0.54426840
## MB STTH BHHE WTTR PCU NMIN YR
## 0.55884933 0.57312152 0.58699870 0.60070283 0.61411837 0.62701684 0.63959677
## VS CST WWT WBSW WG
## 0.65216691 0.66462238 0.67687001 0.68895184 0.70088989
##
## $`Box-Ironbark_River Red Gum`
## BHHE SCR SPP SKF GAL RWB WPHE
## 0.02714651 0.05218454 0.07677084 0.10080448 0.12462108 0.14750404 0.17018524
## MGLK RFC RCR WAG LFB AMAG WEHE
## 0.19258823 0.21477106 0.23689536 0.25894885 0.28006010 0.30096064 0.32182808
## FHE SCC DB BTH YFHE JW RWH
## 0.34093139 0.35999164 0.37869065 0.39676311 0.41466245 0.43159405 0.44824770
## CBW BRTH BTR YTH WNHE FLAME MUSK
## 0.46458524 0.48062497 0.49665684 0.51262336 0.52853850 0.54419753 0.55954408
## STP WTG RBEE GCU OBO EYR SIL
## 0.57443580 0.58903808 0.60361682 0.61817528 0.63246247 0.64659320 0.66060525
## WTTR STTH NMIN
## 0.67447486 0.68762196 0.70065879
macnally <- macnally %>% mutate(HABITAT = factor(HABITAT))
macnally.dist <- vegdist(macnally[, -1], "bray")
macnally.adonis <- adonis2(macnally.dist ~ HABITAT, data = macnally)
macnally.adonis
EcolUtils::adonis.pair(macnally.dist, macnally$HABITAT)
betadisp = PERMDISP2
Analysis of multivariate homogeneity of group dispersions (variances) - test for homogeneity of variance to test whether the dispersions (variances) of one or more groups are differnt, the distances of group memebers to the group centroid are subject to ANOVA.
macnally.disp <- betadisper(macnally.dist, macnally$HABITAT)
boxplot(macnally.disp)
plot(macnally.disp)
anova(macnally.disp)
permutest(macnally.disp, pairwise = TRUE)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 5 0.19897 0.039795 3.1217 999 0.024 *
## Residuals 31 0.39518 0.012748
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
## Box-Ironbark Foothills Woodland Gipps.Manna Mixed
## Box-Ironbark 0.718000 1.000000 0.081000
## Foothills Woodland 0.679935 0.642000 0.091000
## Gipps.Manna 0.996642 0.596933 0.076000
## Mixed 0.077513 0.117360 0.074565
## Montane Forest 0.585643 0.255825 0.443024 0.042170
## River Red Gum 0.806495 0.540700 0.774181 0.057434
## Montane Forest River Red Gum
## Box-Ironbark 0.633000 0.818
## Foothills Woodland 0.263000 0.584
## Gipps.Manna 0.485000 0.783
## Mixed 0.032000 0.064
## Montane Forest 0.874
## River Red Gum 0.862877
TukeyHSD(macnally.disp)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr
## Foothills Woodland-Box-Ironbark 0.0181084119 -0.22420933 0.26042615
## Gipps.Manna-Box-Ironbark 0.0001671479 -0.24215059 0.24248489
## Mixed-Box-Ironbark 0.1423698309 -0.04806895 0.33280861
## Montane Forest-Box-Ironbark -0.0217402832 -0.26405802 0.22057746
## River Red Gum-Box-Ironbark -0.0135529859 -0.25587072 0.22876475
## Gipps.Manna-Foothills Woodland -0.0179412640 -0.26025900 0.22437648
## Mixed-Foothills Woodland 0.1242614191 -0.06617736 0.31470020
## Montane Forest-Foothills Woodland -0.0398486950 -0.28216643 0.20246904
## River Red Gum-Foothills Woodland -0.0316613978 -0.27397914 0.21065634
## Mixed-Gipps.Manna 0.1422026830 -0.04823610 0.33264147
## Montane Forest-Gipps.Manna -0.0219074311 -0.26422517 0.22041031
## River Red Gum-Gipps.Manna -0.0137201338 -0.25603787 0.22859761
## Montane Forest-Mixed -0.1641101141 -0.35454890 0.02632867
## River Red Gum-Mixed -0.1559228168 -0.34636160 0.03451597
## River Red Gum-Montane Forest 0.0081872972 -0.23413044 0.25050504
## p adj
## Foothills Woodland-Box-Ironbark 0.9999087
## Gipps.Manna-Box-Ironbark 1.0000000
## Mixed-Box-Ironbark 0.2369563
## Montane Forest-Box-Ironbark 0.9997755
## River Red Gum-Box-Ironbark 0.9999782
## Gipps.Manna-Foothills Woodland 0.9999128
## Mixed-Foothills Woodland 0.3758087
## Montane Forest-Foothills Woodland 0.9958419
## River Red Gum-Foothills Woodland 0.9986049
## Mixed-Gipps.Manna 0.2380525
## Montane Forest-Gipps.Manna 0.9997669
## River Red Gum-Gipps.Manna 0.9999769
## Montane Forest-Mixed 0.1235566
## River Red Gum-Mixed 0.1596980
## River Red Gum-Montane Forest 0.9999982
Now with bias correction
Use the spatial median rather than the centroid (default)
If the median or centroid is calculated from the same data as then used to calculate dispersion, dispersion will be biased downwards (less dispersion)
Adjust for small sample bias (default is false) can also be biased by unequal sample sizes good idea to correct for bias when sample sizes are small or uneven
macnally.disp <- betadisper(macnally.dist, macnally$HABITAT, type = "median", bias.adjust = TRUE)
boxplot(macnally.disp)
plot(macnally.disp)
anova(macnally.disp)
permutest(macnally.disp, pairwise = TRUE)
##
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
##
## Response: Distances
## Df Sum Sq Mean Sq F N.Perm Pr(>F)
## Groups 5 0.14036 0.028071 2.0076 999 0.091 .
## Residuals 31 0.43346 0.013983
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Pairwise comparisons:
## (Observed p-value below diagonal, permuted p-value above diagonal)
## Box-Ironbark Foothills Woodland Gipps.Manna Mixed
## Box-Ironbark 0.739000 0.996000 0.152000
## Foothills Woodland 0.679935 0.632000 0.208000
## Gipps.Manna 0.996642 0.596933 0.136000
## Mixed 0.153431 0.232587 0.148234
## Montane Forest 0.585643 0.255825 0.443024 0.082484
## River Red Gum 0.806495 0.540700 0.774181 0.112695
## Montane Forest River Red Gum
## Box-Ironbark 0.631000 0.837
## Foothills Woodland 0.274000 0.592
## Gipps.Manna 0.464000 0.806
## Mixed 0.071000 0.105
## Montane Forest 0.884
## River Red Gum 0.862877
TukeyHSD(macnally.disp)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = distances ~ group, data = df)
##
## $group
## diff lwr upr
## Foothills Woodland-Box-Ironbark 0.0209097929 -0.23287272 0.27469230
## Gipps.Manna-Box-Ironbark 0.0001930058 -0.25358951 0.25397552
## Mixed-Box-Ironbark 0.1174634907 -0.08198552 0.31691250
## Montane Forest-Box-Ironbark -0.0251035167 -0.27888603 0.22867899
## River Red Gum-Box-Ironbark -0.0156496401 -0.26943215 0.23813287
## Gipps.Manna-Foothills Woodland -0.0207167871 -0.27449930 0.23306572
## Mixed-Foothills Woodland 0.0965536978 -0.10289531 0.29600270
## Montane Forest-Foothills Woodland -0.0460133096 -0.29979582 0.20776920
## River Red Gum-Foothills Woodland -0.0365594331 -0.29034194 0.21722308
## Mixed-Gipps.Manna 0.1172704849 -0.08217852 0.31671949
## Montane Forest-Gipps.Manna -0.0252965225 -0.27907903 0.22848599
## River Red Gum-Gipps.Manna -0.0158426459 -0.26962516 0.23793987
## Montane Forest-Mixed -0.1425670074 -0.34201601 0.05688200
## River Red Gum-Mixed -0.1331131308 -0.33256214 0.06633588
## River Red Gum-Montane Forest 0.0094538765 -0.24432863 0.26323639
## p adj
## Foothills Woodland-Box-Ironbark 0.9998523
## Gipps.Manna-Box-Ironbark 1.0000000
## Mixed-Box-Ironbark 0.4879638
## Montane Forest-Box-Ironbark 0.9996380
## River Red Gum-Box-Ironbark 0.9999647
## Gipps.Manna-Foothills Woodland 0.9998588
## Mixed-Foothills Woodland 0.6854637
## Montane Forest-Foothills Woodland 0.9934491
## River Red Gum-Foothills Woodland 0.9977754
## Mixed-Gipps.Manna 0.4897552
## Montane Forest-Gipps.Manna 0.9996242
## River Red Gum-Gipps.Manna 0.9999625
## Montane Forest-Mixed 0.2803082
## River Red Gum-Mixed 0.3514904
## River Red Gum-Montane Forest 0.9999971